package com.qmth.gkwb.data.pay;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qmth.gkwb.data.document.Pay;
import com.qmth.gkwb.data.document.Student;
import com.qmth.gkwb.data.repository.DictSpecialtyRepo;
import com.qmth.gkwb.data.repository.DictSportRepo;

@Service
public class AmountService {

	@Autowired private DictSportRepo sportRepo;
	@Autowired private DictSpecialtyRepo spcRepo;
	
	public double getAmount(Student student){
		double amount = 0.00;
		if(student == null || student.getSubjectType() == null){
			throw new NullPointerException("报名信息不存在");
		}
		if(student.getSubjectType().equals("SPORT") && student.getSportSigned() == 1){
			amount = sportRepo.findOne(student.getSport().getId()).getCost();
		}
		else if(student.getSubjectType().equals("ART")){
			amount = spcRepo.findOne(1L).getCost();
		}
		return amount;
	}
	
}
